import React, { ComponentType } from 'react';

function Template<T = any>(Wrapper: ComponentType<T>, wrapperProps?: T): any {
    return (component: any) => {
        class WrapperComponent extends component {
            render() {
                //return React.createElement(Wrapper, { children: React.createElement(component, this.props) });
                return (
                    <Wrapper {...wrapperProps}>
                        {React.createElement(component, this.props)}
                    </Wrapper>
                );
            }
        }
        return WrapperComponent;
    };
}

export { Template };
